package com.example.weather;

import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class CitySelectActivity extends Activity {
	
	private ListView list;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.city_select);
		list = (ListView) findViewById(android.R.id.list);
		Intent intent = getIntent();
		final String province = intent.getExtras().getString("province");
		WebServiceHelper wsh = new WebServiceHelper();
		final List<String> cities = wsh.getCities(province);
		list.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, cities));
		list.setOnItemClickListener(new OnItemClickListener(){
			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				// TODO Auto-generated method stub
				Intent i = new Intent();
				i.putExtra("city", cities.get(position));
				i.setClass(CitySelectActivity.this, WeatherActivity.class);
				startActivity(i);
			}
		});
	}

	
}